<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=no"/>
<title>野趣-奔跑</title>
<link href="/Public/css/event/yq.css" type="text/css" rel="stylesheet" />
<link href="/Public/css/event/font.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/Public/js/event/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript" src="/Public/js/event/yqmain.js"></script>
</head>
<body>
<!-------------------------成功------------------------------->
<div class="weixinAlert borderRadius">
    <p class="pVote">为TA加油成功！您今天还剩余5次</p>
    <div class="voteSure borderRadius">确定</div>
</div>
<!-------------------------成功-------------------------------->
<!-------------------------分享------------------------------->
<div class="mask"></div>
<div class="share" ></div>
<div class="ewms borderRadius">
	<span class="icon iconfont icon-chahao closeEwm"></span>
	<h1 class="h1ewms">二维码加油</h1>
    <div class="divewmImg"><img src="/Public/images/event/qrcode.jpg" width="100%"></div>
    <p class="pewm">微信扫描此二维码</p>
    <p class="pewm">让小伙伴给<span class="bold font16">‘{$result['name']}’</span>队加油</p>
</div>
<!------------------------分享END-------------------------------->
<div class="titleBg"><a href="{:U('Wap/Event/organiztions', array( 'event' => $result['event_id'] ) )}">查看冠军榜</a></div>
<div class="bannerBg">
    <img src="/Public/images/event/detailBanner.jpg">
    <div class="yuan"><img src="/Public/images/event/{$result['headimg']}" class="headPic"></div>
</div>
<div class="detail">
    <div class="yqtitle">{$result['name']}</div>
    <php>
    $members = explode( ',', $result['member'] );
    </php>
    <div class="detailInfo">组员:<span>{$members[0]}</span><span>{$members[1]}</span></div>
    <if condition="$result['school'] neq null">
        <div class="detailInfo">学校:<span>{$result['school']}</span></div>
    </if>
    <div class="detailInfo fl">得分:<span id="scoredValue">{$result['score']}</span><div class="detailInfo fr marL40">排名：<span id="rankedValue">{$result['rank']}</span></div></div>
</div>
<div class="dynamicValue"><span id="praisedValue">{$result['praise']}</span><em>活力值</em></div>
<if condition="$passed eq true">
<input class="detailBtn" type="button" value="为TA加油">
<else />
<input class="detailBtn" type="button" value="为TA加油" disabled style='color:#ccc;border:1px solid #ccc'>
</if>
<div class="divShare">
    <div class="shareAll">
        <span class="shareBtn borderRadius">分享给同学</span>
        <span class="shareBtn lpBtn borderRadius">让更多人TA加油</span>
    </div>
</div>
<div class="divfooter bot50">
    <p>浙报公司新媒体服务部技术支持</p>
    <p class="pFooter">浙江日报新闻发展有限公司 | Copyright © 2014 - 2015</p>
</div>
<div class="divCreatBtn"><a href="http://www.zbxinmeiti.com/index.php?m=Wap&c=Enroll&a=individual&enroll=7">我也要为我的战队搭建平台</a></div>
</body>
<script type="text/javascript">
yequ.praise.init({
    selector: '.detailBtn',
    event: "{$result['event_id']}",
    organiztion: "{$result['id']}",
    beforeCallback: function(){
        console.log( 'begin praise' );
    },
    successCallback: function( result ){

        if( result.success == false ){
            if( !result.status ){
                $( ".weixinAlert" ).find( ".pVote" ).html( "投票需要关注" );
                $(".weixinAlert").css('display', 'block');
                $(".mask").css('display', 'block');

                setTimeout( function(){
                    $( ".voteSure" ).trigger( "click" );
                    $( ".lpBtn" ).trigger( 'click' );
                }, 800 );
            }else if( result.rule.day_num - 1 <= 0 ){
                $( ".weixinAlert" ).find( ".pVote" ).html( "今天投票机会已经用完" );
                $( '.detailBtn' ).attr( 'disabled', true);
                $( '.detailBtn' ).css( 'color', '#ccc' );
                $( '.detailBtn' ).css( 'border', '1px solid #ccc' );

                $(".weixinAlert").css('display', 'block');
                $(".mask").css('display', 'block');

            }else if( result.rule.per_days_num - 1 <= 0 ){
                $( ".weixinAlert" ).find( ".pVote" ).html( "给该团队投票机会已经用完" );
                $( '.detailBtn' ).attr( 'disabled', true);
                $( '.detailBtn' ).css( 'color', '#ccc' );

                $( '.detailBtn' ).css( 'border', '1px solid #ccc' );

                $(".weixinAlert").css('display', 'block');
                $(".mask").css('display', 'block');

            }else if( result.rule.per_day_num - 1 <= 0 ){
                $( ".weixinAlert" ).find( ".pVote" ).html( "今天给该团队投票机会已经用完" );
                $( '.detailBtn' ).attr( 'disabled', true);
                $( '.detailBtn' ).css( 'color', '#ccc' );

                $( '.detailBtn' ).css( 'border', '1px solid #ccc' );

                $(".weixinAlert").css('display', 'block');
                $(".mask").css('display', 'block');
            }
        }else{
            if( result.rule.day_num - 1 <= 0 ){
                $( '.detailBtn' ).attr( 'disabled', true);
                $( '.detailBtn' ).css( 'color', '#ccc' );

                $( '.detailBtn' ).css( 'border', '1px solid #ccc' );
            }else if( result.rule.per_days_num - 1 <= 0 ){
                $( '.detailBtn' ).attr( 'disabled', true);
                $( '.detailBtn' ).css( 'color', '#ccc' );

                $( '.detailBtn' ).css( 'border', '1px solid #ccc' );
            }else if( result.rule.per_day_num - 1 <= 0 ){
                $( '.detailBtn' ).attr( 'disabled', true);
                $( '.detailBtn' ).css( 'color', '#ccc' );

                $( '.detailBtn' ).css( 'border', '1px solid #ccc' );
            }

            $( ".weixinAlert" ).find( ".pVote" ).html( "投票成功" );
            $( ".weixinAlert" ).css( 'display', 'block' );
            $(".mask").css('display', 'block');

            $( '#scoredValue' ).html( result.updated.score );
            $( '#rankedValue' ).html( result.updated.rank );
            $( '#praisedValue' ).html( result.updated.praise );
        }
    },
    errorCallback: function(){
        console.log( 'praise error' );
    }
});
</script>
<script type="text/javascript">
wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: '{$wx["appid"]}', // 必填，公众号的唯一标识
    timestamp: "{$wx['timestamp']}", // 必填，生成签名的时间戳
    nonceStr: "{$wx['noncestr']}", // 必填，生成签名的随机串
    signature: "{$wx['sha1']}",// 必填，签名，见附录1
    jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});
wx.error(function(res){
    //console.log(res);
    // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
});
wx.ready( function( e ){
    wx.onMenuShareAppMessage({
        title: "奔跑吧，杭小商", // 分享标题
        desc: "一起跑风景，一起撒野，趣享生活。", // 分享描述
        link: location.protocol + "//" + window.location.hostname + "{$_SERVER['REQUEST_URI']}", // 分享链接
        imgUrl: location.protocol + "//" + window.location.hostname + "/Public/images/event/share_event.jpg", // 分享图标
        type: 'link', // 分享类型,music、video或link，不填默认为link
        dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
        success: function () {
            // 用户确认分享后执行的回调函数
        },
        cancel: function () {
            // 用户取消分享后执行的回调函数
        }
    });
    wx.onMenuShareTimeline({
        title: "奔跑吧，杭小商", // 分享标题
        link: location.protocol + "//" + window.location.hostname + "{$_SERVER['REQUEST_URI']}", // 分享链接
        imgUrl: location.protocol + "//" + window.location.hostname + "/Public/images/event/share_event.jpg", // 分享图标
        success: function () {
            // 用户确认分享后执行的回调函数
        },
        cancel: function () {
            // 用户取消分享后执行的回调函数
        }
    });
})
</script>

</html>
